package com.symria.server.dao.common;

import com.symria.framework.dao.util.TemplateDao;
import com.symria.framework.page.Page;
import com.symria.server.po.CustomInfo;
import com.symria.server.po.UserInfo;
import com.symria.system.constants.ATTSystem;
import com.symria.system.statement.Statement;

public class AdminDao extends TemplateDao {
	

	
    public boolean haveUser(String username){
		Statement stms = stmsFactory.createStatement(" from UserInfo u where u.userName=?");
		          stms.addParam(username);
    	return templateDao.query(stms).iterator().hasNext();
	}
    public void searchChannel(UserInfo user,Page page){
    	Statement stms = stmsFactory.createStatement(" from UserInfo u where u.roleId=?");
    	          stms.addParam(ATTSystem.CHANNEL_ROLE_ID);
    	          if(null!=user){
    	        	  stms.appendLike(null, "and", "u.companyName", user.getCompanyName());
    	        	  stms.appendLike(null, "and", "u.status", user.getStatus());
    	        	  stms.append("and", "u.userId", "=", user.getUserId());
    	        	  stms.appendLike(null, "and", "u.realName", user.getRealName());
    	          }
    	          stms.addOrderBy(" u.userId desc");
    	          templateDao.search(stms, page);
    }
    public void searchCustomInfo(CustomInfo c,Page page){
    	Statement stms = stmsFactory.createStatement("from CustomInfo where 1=1");
    	          if(null!=c){
    	        	  stms.appendLike(null, "and", "comName", c.getComName());
    	        	  stms.appendLike(null, "and", "email", c.getEmail());
    	        	  stms.appendLike(null, "and", "callUser", c.getCallUser());
    	          }
    	          stms.addOrderBy(" id desc");
    	templateDao.search(stms, page);          
    }
    
    
}
